import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Player {

	private String name;
	private int score;
	private int nbElements;
	private int currentElement;
	List<RPSEnum> list;

	/**
	 * 
	 * @param name
	 * @param list
	 */
	public Player(String name, List<RPSEnum> list) {
		this.name = name;
		this.list = list;
		this.score = 0;
		this.nbElements = 10;
		this.currentElement = 0;
	}

	/**
	 * 
	 * @param name
	 */
	public Player(String name) {
		this.name = name;
		this.score = 0;
		this.nbElements = 10;
		this.currentElement = 0;
		this.list = new ArrayList<RPSEnum>();
		randomlist();
	}

	public int getScore() {
		return score;
	}

	public String getName() {
		return name;
	}

	public RPSEnum getNextMove() {
		//reset when new game session
		if (currentElement == 10) {
			currentElement = 0;
			score = 0;
		}
		if (currentElement < 10) {
			RPSEnum rp = list.get(currentElement);
			currentElement++;
			return rp;
		}

		return null;
	}

	public void setScore(int s) {
		score = s;
	}

	private void randomlist() {
		Random r = new Random();
		for (int i = 0; i < nbElements; i++) {
			int rand = r.nextInt(3);

			if (rand == 0)
				list.add(RPSEnum.PAPER);

			else if (rand == 1)
				list.add(RPSEnum.ROCK);

			else if (rand == 2)
				list.add(RPSEnum.SCISSORS);
		}
	}
}
